 /*******************************************************************
 * add by allen.qiang 20-170923
 * 网站日志JS PC/WAP通用
 ******************************************************************/
(function () {
    function e_track() {
        /* 初始化参数 */
        var session_id = E.getCookie('PHPSESSID'), /* 访客标识 */
            user_name = E.getCookie('user_name') , /* 访客用户名 */
            referrer = E.getReferrer(),
            referrer_obj = E.parseURL(referrer),
            current_url_obj = E.parseURL(E.getUrl()),
            key1 = current_url_obj.params.key1 ? current_url_obj.params.key1 : '',
            key2 = current_url_obj.params.key2 ? current_url_obj.params.key2 : '',
            key3 = current_url_obj.params.key3 ? current_url_obj.params.key3 : '',
            source_type = E.getDevice() == 'pc' ? 'pc' : 'wap';/* 1：pc、2：wap */

        /* 判断用户名 */
        if (!user_name || user_name == 'null') {
            user_name = '';
        }
        /* 初始化跟踪代码 */
        var tracker_code = '';
        /* 获取跟踪代码 */
        if (current_url_obj.params.tracker_code) {
            tracker_code = current_url_obj.params.tracker_code;
        } else if (current_url_obj.params.tracker_u) {
            tracker_code = current_url_obj.params.tracker_u;
        } else if (current_url_obj.params.t) {
            tracker_code = current_url_obj.params.t;
        }

        /* 判断跟踪代码 */
        if (tracker_code != '') {
            E.setCookie('tracker_code', tracker_code, 3600 * 24 * 7);
        }
        if (key1 != '') {
            E.setCookie('__etrack_key1', key1, 3600 * 24 * 7);
        }
        if (key2 != '') {
            E.setCookie('__etrack_key2', key2, 3600 * 24 * 7);
        }
        if (key3 != '') {
            E.setCookie('__etrack_key3', key3, 3600 * 24 * 7);
        }

        /* 取Cookie中的key1、key2、key3 */
        key1 = E.getCookie('__etrack_key1');
        key2 = E.getCookie('__etrack_key2');
        key3 = E.getCookie('__etrack_key3');

        /* 来源网址 */
        E.setCookie('__etrack_referrer_url', referrer, 3600 * 24 * 7);

        var request_string = 'referer_url=' + encodeURIComponent(referrer) +
            '&access_url=' + encodeURIComponent(E.getUrl()) +
            '&userAgent=' + E.browser() +
            '&user_name=' + user_name +
            '&session_id=' + session_id +
            '&source_type=' + source_type +
            '&screen_resolution=' + E.getScreen() +
            //'&page_name1=' + G.args.page_name +
            //'&page_name2=' + G.args.sub_page_name +
            //'&is_register=' + is_register +
            '&device=' + E.getDevice() +
            '&browser=' + E.browser() +
            '&tracker_code=' + tracker_code +
            '&key1=' + key1 +
            '&key2=' + key2 +
            '&key3=' + key3;
            //'&logintype=' + login_type +
            //'&city_id=' + city_id;
        var url = '/common/track?' + request_string;
        /* 插入iframe */
        var iframe = document.createElement('iframe');
        iframe.height = 0;
        iframe.width = 0;
        iframe.style.visibility = 'hidden';
        iframe.style.display = 'none';
        iframe.frameborder = 0;
        iframe.src = url;
        document.body.appendChild(iframe);
    }

    e_track();
})();